<template>
  <div class="universe-visualization">
    <div class="stars-container">
      <div v-for="i in 50" :key="i" class="star" :style="getRandomStarStyle()"></div>
    </div>
    <div class="planet-container">
      <div class="planet earth" :class="{ 'pulse': showPulse }">
        <div class="planet-label">我们的宇宙</div>
      </div>
      <div class="wormhole" :class="{ 'active': isTransitioning }">
        <div v-for="i in 5" :key="i" class="wormhole-ring"></div>
      </div>
      <div class="planet parallel" :class="{ 'pulse': showPulse }">
        <div class="planet-label">平行宇宙</div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    isTransitioning: {
      type: Boolean,
      default: false
    },
    showPulse: {
      type: Boolean,
      default: false
    }
  },
  methods: {
    getRandomStarStyle() {
      const size = Math.random() * 3 + 1;
      const top = Math.random() * 100;
      const left = Math.random() * 100;
      const animationDelay = Math.random() * 3;
      
      return {
        width: `${size}px`,
        height: `${size}px`,
        top: `${top}%`,
        left: `${left}%`,
        animationDelay: `${animationDelay}s`
      };
    }
  }
}
</script>

<style scoped>
.universe-visualization {
  position: relative;
  height: 200px;
  overflow: hidden;
  border-radius: 8px;
  margin: 20px 0;
  background: linear-gradient(to bottom, #0f2027, #203a43, #2c5364);
}

.stars-container {
  position: absolute;
  width: 100%;
  height: 100%;
}

.star {
  position: absolute;
  background-color: white;
  border-radius: 50%;
  animation: twinkle 3s infinite alternate;
}

@keyframes twinkle {
  0% { opacity: 0.3; }
  100% { opacity: 1; }
}

.planet-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 100%;
  padding: 0 50px;
  position: relative;
}

.planet {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  position: relative;
  box-shadow: 0 0 20px rgba(255, 255, 255, 0.3);
}

.planet.earth {
  background: radial-gradient(circle at 30% 30%, #4b6cb7, #182848);
}

.planet.parallel {
  background: radial-gradient(circle at 30% 30%, #8e2de2, #4a00e0);
}

.planet.pulse {
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { transform: scale(1); box-shadow: 0 0 20px rgba(255, 255, 255, 0.3); }
  50% { transform: scale(1.05); box-shadow: 0 0 30px rgba(255, 255, 255, 0.5); }
  100% { transform: scale(1); box-shadow: 0 0 20px rgba(255, 255, 255, 0.3); }
}

.planet-label {
  position: absolute;
  bottom: -25px;
  left: 50%;
  transform: translateX(-50%);
  color: white;
  font-size: 12px;
  white-space: nowrap;
}

.wormhole {
  position: relative;
  width: 100px;
  height: 40px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.wormhole-ring {
  position: absolute;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  opacity: 0.7;
}

.wormhole-ring:nth-child(1) { width: 20px; height: 10px; }
.wormhole-ring:nth-child(2) { width: 40px; height: 15px; }
.wormhole-ring:nth-child(3) { width: 60px; height: 20px; }
.wormhole-ring:nth-child(4) { width: 80px; height: 25px; }
.wormhole-ring:nth-child(5) { width: 100px; height: 30px; }

.wormhole.active .wormhole-ring {
  animation: wormhole-pulse 2s infinite;
}

@keyframes wormhole-pulse {
  0% { transform: scale(1); opacity: 0.7; }
  50% { transform: scale(1.1); opacity: 1; }
  100% { transform: scale(1); opacity: 0.7; }
}
</style>